package data;
import java.lang.reflect.Type;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;

public class CompanyInfo {
	private String mName = "";
	private String mAddress1 = "";
	private String mAddress2 = "";
	private String mContact = "";
	private int mImage = 0;

	public CompanyInfo() {
		
	}
	
	public CompanyInfo(String name, String address1, String address2, String contact, int image) {
		mName = name;
		mAddress1 = address1;
		mAddress2 = address2;
		mContact = contact;
		mImage = image;
	}

	public String getName() {
		return mName;
	}

	public String getAddress1() {
		return mAddress1;
	}

	public String getAddress2() {
		return mAddress2;
	}

	public String getContact() {
		return mContact;
	}

	public int getImage() {
		return mImage;
	}

	public final static JsonDeserializer<CompanyInfo> deserializer = new JsonDeserializer<CompanyInfo>() {

		@Override
		public CompanyInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
				throws JsonParseException {
			
			String name = json.getAsJsonObject().get("name").getAsString();
			String address1 = json.getAsJsonObject().get("address1").getAsString();
			String address2 = json.getAsJsonObject().get("address2").getAsString();
			String contact = json.getAsJsonObject().get("contact").getAsString();
			int image = json.getAsJsonObject().get("image").getAsInt();
            return new CompanyInfo(name, address1, address2, contact, image);
		}
	};
}
